<div class="row">
    <div class="col-md-12 widget-module">
        <div class="box-widget">
            <div class="widget-head clearfix">
                <h4 class="pull-left"><?php echo $this->translate('edit profile'); ?></h4>
            </div>
            <div class="widget-container">
                <div class="widget-block">
                    <div class="widget-content">
                        <form enctype="multipart/form-data" method="post" class="form-horizontal form-box">
                            <div class="form-group <?php echo $this->classError['last_name']; ?>">
                                <label class="col-lg-2 control-label"><?php echo $this->translate('last name'); ?></label>
                                <div class="col-lg-4">
                                    <input type="text" value="<?php echo $this->data['last_name']; ?>" name="last_name" class="form-control" placeholder="<?php echo $this->translate('last name'); ?>" />
                                    <?php echo $this->messageError['last_name']; ?>
                                </div>
                            </div>
                            
                            <div class="form-group <?php echo $this->classError['first_name']; ?>">
                                <label class="col-lg-2 control-label"><?php echo $this->translate('first name'); ?></label>
                                <div class="col-lg-4">
                                    <input type="text" value="<?php echo $this->data['first_name']; ?>" name="first_name" class="form-control" placeholder="<?php echo $this->translate('first name'); ?>" />
                                    <?php echo $this->messageError['first_name']; ?>
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-lg-2 control-label"><?php echo $this->translate('avatar'); ?></label>
                                <div class="col-lg-6">
                                    <div class="input-group">
                                        <input id="avatar" class="form-control" type="text" value="<?php echo $this->data['avatar']; ?>" name="avatar" class="form-control" placeholder="<?php echo $this->translate('avatar'); ?>" />
                                        <span class="input-group-btn">
                                            <a id="iframe-btn" href="<?php echo $this->baseUrl(); ?>/filemanager/dialog.php?type=1&subfolder=&editor=mce_0&field_id=avatar">
                                                <button class="btn btn-default" type="button">
                                                    <span class="icon-folder-open" aria-hidden="true"></span>
                                                </button>
                                            </a>
                                        </span>
                                    </div>
                                </div>
                            </div>
                            
                            <?php
                                if(!isset($this->data['avatar'])){
                                    $src = $this->templateURL . "/images/grid-default-thumb.png";
                                }else{
                                    $src = $this->data['avatar'];
                                }
                            ?>
                            
                            <div class="form-group">
                                <label class="col-lg-2 control-label"><?php echo $this->translate('current avatar'); ?></label>
                                <div class="col-lg-6">
                                    <div class="current-image">
                                        <img class="current-image" src="<?php echo $src; ?>" />
                                    </div>
                                </div>
                            </div>
                            
                            <div class="form-group <?php echo $this->classError['identity_number']; ?>">
                                <label class="col-lg-2 control-label"><?php echo $this->translate('identity number'); ?></label>
                                <div class="col-lg-4">
                                    <input type="text" value="<?php echo $this->data['identity_number']; ?>" name="identity_number" class="form-control" placeholder="<?php echo $this->translate('identity number'); ?>" />
                                    <?php echo $this->messageError['identity_number']; ?>
                                </div>
                            </div>
                            
                            <div class="form-group <?php echo $this->classError['date_of_birth']; ?>">
                                <label class="col-lg-2 control-label"><?php echo $this->translate('date_of_birth'); ?></label>
                                <div class="col-lg-4">
                                    <input id="dp1" type="text" value="<?php if(isset($this->data['date_of_birth'])) echo date("d-m-Y", strtotime($this->data['date_of_birth'])); ?>" name="date_of_birth" class="form-control" placeholder="<?php echo $this->translate('date_of_birth'); ?>" />
                                    <?php echo $this->messageError['date_of_birth']; ?>
                                </div>
                            </div>
                            
                            <div class="form-group <?php echo $this->classError['address']; ?>">
                                <label class="col-lg-2 control-label"><?php echo $this->translate('address'); ?></label>
                                <div class="col-lg-4">
                                    <input type="text" value="<?php echo $this->data['address']; ?>" name="address" class="form-control" placeholder="<?php echo $this->translate('address'); ?>" />
                                    <?php echo $this->messageError['address']; ?>
                                </div>
                            </div>
                            
                            <div class="form-group <?php echo $this->classError['phone_number']; ?>">
                                <label class="col-lg-2 control-label"><?php echo $this->translate('phone number'); ?></label>
                                <div class="col-lg-4">
                                    <input type="text" value="<?php echo $this->data['phone_number']; ?>" name="phone_number" class="form-control" placeholder="<?php echo $this->translate('phone number'); ?>" />
                                    <?php echo $this->messageError['phone_number']; ?>
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-lg-2 control-label"><?php echo $this->translate('gender'); ?></label>
                                <div class="col-lg-4">
                                    <div class="radio">
                                        <label>
                                            <input type="radio" <?php if($this->data['gender'] == 0) echo 'checked=""'; ?> value="0" name="gender" />
                                            <?php echo $this->translate('male'); ?>
                                        </label>
                                    </div>
                                    <div class="radio">
                                        <label>
                                            <input type="radio" <?php if($this->data['gender'] == 1) echo 'checked=""'; ?> value="1" name="gender" />
                                            <?php echo $this->translate('female'); ?>
                                        </label>
                                    </div>
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-lg-2 control-label">&nbsp;</label>
                                <div class="col-lg-5">
                                    <div class="form-actions">
                                        <button type="submit" class="btn btn-primary">
                                            <i class="icon-save"></i>
                                            <?php echo $this->translate('save'); ?>
                                        </button>
                                        <button id="cancel" type="button" class="btn">
                                            <i class="icon-cancel-circle-2"></i>
                                            <?php echo $this->translate('cancel'); ?>
                                        </button>
                                    </div>
                                </div>
                            </div>
                            <?php if(isset($this->user_id) && $this->user_id > 0): ?>
                            <input id="id" type="hidden" name="id" value="<?php echo $this->user_id; ?>" />
                            <input type="hidden" name="save" value="1" />
                            <?php endif; ?>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
$("#cancel").click(function(){
    window.location = "<?php echo $this->url(array('module' => 'admin', 'controller' => 'user', 'action' => 'index'), null, true); ?>";
});

$("#avatar").change(function(){
    $("#has-avatar").val("1");
});

$(function() {
    /*==DATE PICKER==*/
    $('#dp1').datepicker({
        format: 'dd-mm-yyyy',
        viewMode: 2,
    });
    
    $('#iframe-btn').fancybox({	
    	'width'		: 900,
    	'height'	: 600,
    	'type'		: 'iframe',
        'autoScale'    	: false,
        'margin'    : 70,
    });
});
</script>